<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台主页模块 - XzcBlogTemplate后台管理</title>
    <link rel="stylesheet" href="static/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="static/admin/css/common.css">
    <link rel="stylesheet" type="text/css" href="static/admin/css/blogadd.css">
</head>
<body>
<div class="layui-container main">
    <div class="layui-row layui-col-space20">
        <div class="layui-col-md12">
            <p>
		        	<span class="layui-breadcrumb" style="visibility: visible;">
			          	<a href="bloglist.html">博客管理系统</a><span lay-separator="">/</span>
			          	<a href="bloglist.html">后台首页</a><span lay-separator="">/</span>
			          	<a><cite>博文添加</cite></a>
		        	</span>
            </p>
        </div>
        <div class="layui-col-md12">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label id="title" class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" required lay-verify="required" placeholder="请输入标题"
                               autocomplete="off" class="layui-input max_width500">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label id="detail" class="layui-form-label">分类</label>
                    <div class="layui-input-block">
                        <select name="city" lay-verify="required">
                            <option value="" class="max_width500"></option>
                            <option value="1" class="max_width500">JAVA基础</option>
                            <option value="2" class="max_width500">数据库</option>
                            <option value="3" class="max_width500">JSP</option>
                            <option value="4" class="max_width500">框架</option>
                            <option value="5" class="max_width500">微服务</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">置顶</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="switch" lay-skin="switch" value="true">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">   <!-- style="display: none;"-->
                        <textarea name="desc" placeholder="请输入内容" class="layui-textarea" id="editor"
                        ></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button name="button" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script src="static/js/jquery-1.12.4.min.js"></script>
<script src="static/layui/layui.all.js"></script>
<script src="static/admin/javascript/blogadd.js"></script>
<script>
    $(document).ready(function () {
        $("[name=\"button\"]").click(function () {
            var title = $("[name=\"title\"]").val();
            var tid = $("[name=\"city\"]").val();

            if ($("[name=\"switch\"]").val() === true) {
                var status = 1
            } else {
                var status = 0;
            }
            /*var detail = document.getElementById("editor").value();*/
            let detail = $("#editor").prop('value');
            var uid = sessionStorage.getItem('uid');
            $.get("blog/addByBlogId", {
                "title": title,
                "tid": tid,
                "status": status,
                "detail": detail,
                "uid": uid
            }, function (rs) {
                alert("11111111111111111");
                var mess = rs.result;
                alert(mess)
            })
        })
    })
</script>
</html>